<?php htmlTemplate('admin_header_frame.php');?>
<div class="title">添加区块
</div>
<script type="text/javascript">
function setThumbImg(src){
	$("#thumb").val(src);
}
function checkForm()
{
	var scatid = $.trim($("#scatid").val());
	var type =  $.trim($("#type").val());
	var name = $.trim($("#name").val());
	var keys =  $.trim($("#keys").val());
	var memo =  $.trim($("#memo").val());
	//var section_cate = $.trim($("#section_cate").val());
	var section = $.trim(KE.util.getData('sections'));
	var nums =  $.trim($("#nums").val());
	if (scatid==0){	
		parent.showAlert('请选择区块分类！');	
		return false;	
	}
	if (type==0){	
		parent.showAlert('请选择类型！');	
		return false;	
	}else{
		if(type==2 && section==''){
			parent.showAlert('请添加代码内容！');	
			return false;	
		}
		if(type==1 && nums==''){
			parent.showAlert('请填写推荐位显示条数！');	
			return false;	
		}
	}
	if (name==''){	
		parent.showAlert('名称不能为空！');	
		return false;	
	}
	if(keys==''){
		parent.showAlert('请填写标识！');
		return false;
	}

	<?php 
	if ($section){
		$url = ZSM_WWW_HOST.'admin/section/modify/do/update/id/'.$section['id'];
	}else{
		$url = ZSM_WWW_HOST.'admin/section/add/do/add';
	}
	?>
	var url = '<?php echo $url;?>';
	$("#submitsection").attr({"disabled":"disabled"});
	$.post(url,{'scatid':scatid,'type':type,'name':name,'keys':keys,'memo':memo,'nums':nums,'section':section},function(rs){
		parent.showAlert(rs);
	});
	return false;
}

</script>
<form method="post" action="<?php echo ZSM_WWW_HOST ?>/admin/section/add/do/add" onsubmit="return checkForm()">
<table width="100%" cellspacing="1" cellpadding="3" id="listTable">
	<tr>
		<td align="right">分 类： </td>
		<td><select name="scatid" id="scatid">
			<?php if($section){?>
			<option value="<?php echo $section['scatid']?>"><?php echo $section['cname']?></option>
			<?php }else{
				echo '<option value="0">请选择分类</option>';
			}?>
			<?php foreach ($cate as $key=>$value):?>
			<option value="<?php echo $value['id']?>"><?php echo $value['cname']?></option>
				
			<?php endforeach;?>
		</select>* 用于将区块分类</td>
	</tr>	
	<tr>
		<td align="right">类 型： </td>
		<td><select name="type" id="type">
			<?php if($section){
				if ($section['type']==1){
					$tname = '推荐位';
				}else{
					$tname = '代码';
				}
			?>
			<option value="<?php echo $section['type']?>"><?php echo $tname;?></option>
			<?php }else{
				echo '<option value="0">请选择类型</option>';
			}?>
			
			<option value="1">推荐位</option>
			<option value="2">代码</option>
			
		</select>* 类型分为推荐位和代码</td>
	</tr>
	<tr>
		<td align="right">名 称： </td>
		<td><input type="text" style="width:300px;" id="name" name="name" value="<?php if($section) echo $section['name'];?>">*</td>
	</tr>
	<tr>
		<td align="right">标 识： </td>
		<td><input type="text" style="width:300px;" id="keys" name="keys" value="<?php if($section) echo $section['keys'];?>">* 用英文字母或数字填写，用于区分不同区块</td>
	</tr>
	<tr>
		<td valign="top" align="right">备 注：</td>
		<td><textarea style="width:798px;height:50px;" id="memo" name=""memo""><?php if($section) echo $section['memo'];?></textarea></td>
	</tr>
	<tr>
		<td align="right">显 示： </td>
		<td><input type="text" style="width:50px;" id="nums" name="nums" value="<?php if($section) echo $section['nums'];?>"> 条数，如果上面的类型是推荐位，请在此填写条数</td>
	</tr>
	<tr>
		<td valign="top" align="right"  style="padding-top:10px;" >代 码 ：</td>
		<td  style="padding-top:10px;" >如果上面的类型选择的是代码，请在下面填写代码内容</td>
	</tr>
	<tr>
		<td align="right" valign="top">&nbsp;</td>
		<td  ><?php 
		if ($section){
			$content = $section['section'];			
		}else{
			$content=null;
		}
		
		echo editor('sections',800,300,$content);
		?></td>
	</tr>

	<tr>
		<td align="right"></td>
		<td style="padding-top:10px;"><input id="submitsection" type="submit" value="提 交"  class="submit"  /></td>
	</tr>
</table>
</form>
